home *** CD-ROM | disk | FTP | other *** search
- /* line.c ( rectangle ) */
- /* Entered by A. Wayner */
-
- # include <graphics.h>
- # include <stdlib.h>
-
- main()
- {
- int graphdriver = DETECT;
- int graphmode, x1, x2, y1, y2, maxx, maxy, maxcolor;
-
- /* Detect adapter type and */
- /* initialize graphics system */
- initgraph( &graphdriver, &graphmode, "\\turboc");
- outtextxy( 10, 10, "Random lines with 'line' ");
-
- maxx = getmaxx() - 100;
- maxy = getmaxy() - 60;
- maxcolor = getmaxcolor();
- randomize(); /* Initialize random number generator */
-
- /* Exit when user presses a key */
- outtextxy( 10, getmaxy() - 30,"Press any key to exit : ");
- while( !kbhit())
- {
- /* Generate random end points */
- /* for the lines */
- x1 = random( maxx ) + 50;
- x2 = random( maxx ) + 50;
- y1 = random( maxy ) + 30;
- y2 = random( maxy ) + 30;
-
- setcolor( WHITE );
-
- /* Now draw the line */
- line( x1, y1, x2, y2 );
- }
-
- closegraph(); /* Exit graphics library */
-
- }